<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="wrapper">
      <p class="demo box active"></p>
      <span class="demo"></span>
      <span class="demodemo"></span>
    </div>

    <script>
      Element.prototype.getElementsByClassName =
        Document.prototype.getElementsByClassName =
        document.getElementsByClassName =
          function (className) {
            let targetEl = [];
            const allDomArray = document.getElementsByTagName("*");
            Array.from(allDomArray).forEach((item) => {
              const itemClassName = item.className;
              if (itemClassName.split(" ").includes(className)) {
                targetEl.push(item);
              }
            });
            return targetEl;
          };

      const demoEl = document.getElementsByClassName("demo");
      console.log(demoEl);
    </script>
  </body>
</html>
